<%@ page contentType="text/html;charset=UTF-8" %>
<%@include file="../../common/sessionValidate.jsp" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
<head>
    <title>T_contract信息维护</title>
    <%@ include file="../../common/meta.jsp" %>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <link rel="stylesheet" href="<%=basePath%>css/my-bootstrap.css" media="screen" id="tuserskin">
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <script type="text/javascript" src="<%= basePath %>js/jquery.cookie.js"></script>
</head>
<style>
    hr {
        margin-top: 1px;
        border-bottom: 1px solid #1BBC9B;
    }
</style>
<body>
<form class="form-horizontal form-bordered form-row-strippe" name="ffAdd" id="ffAdd" mentod="post" role="form"
      data-toggle="validator" enctype="multipart/form-data">
    <div class="" style="margin-right:2px;padding-right:1px;">

        <!-------------------------- 面板  start--------------------------------->
        <div class="panel panel-primary">
            <div class="panel-heading clearfix" id="addHeaderDiv">
            </div>
            <div class="panel-body">
                <div class="row">
                    <h5>&nbsp;&nbsp;合同信息</h5>
                    <hr>
                    <div class="col-xs-6"><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font> 合同号</label>
                                <div class="col-xs-9">
                                    <input id="contractno" name="contractno" type="text" class="form-control"
                                           placeholder=""/>
                                    <input id="contractid" name="contractid" type="hidden"/>
                                    <input id="contracttype" name="contracttype" type="hidden" value="租赁合同"/>
                                    <input id="billrowsnum" name="billrowsnum" type="hidden" value="0"/>
                                    <input id="status" name="status" type="hidden" value="待生效"/>

                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>园区对接人</label>
                                <div class="col-xs-9">
                                    <input id="linkman" name="linkman" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>合同金额（元）</label>
                                <div class="col-xs-9">
                                    <input id="totalpriceString" name="totalpriceString" type="text" value="" class="form-control"
                                           placeholder="" onblur="number_format('totalpriceString','totalprice')"/>
                                    <input type="hidden" id="totalprice" name="totalprice" value="">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>签订时间</label>
                                <div class="col-xs-9">
                                    <input id="signtime" name="signtime" type="text" class="form-control"
                                           onclick='SelectDate(this)' readonly='true' placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>合同开始时间</label>
                                <div class="col-xs-9">
                                    <input id="contractstartdate" name="contractstartdate" type="text"
                                           class="form-control"
                                           onclick='SelectDate(this)' readonly='true' placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>合同结束时间</label>
                                <div class="col-xs-9">
                                    <input id="contractenddate" name="contractenddate" type="text" class="form-control"
                                           onclick='SelectDate(this)' readonly='true' placeholder=""/>
                                </div>
                            </div>
                        </div>
                    </div><!--end 换列-->
                </div><!--end row-->
            </div><!--end body-->
        </div>
        <!--------------------------面板 end------------------------------------>

        <!-------------------------- 房源 面板  start--------------------------------->
        <div class="panel panel-primary">
            <div class="panel-body">
                <div class="row">
                    <h5>&nbsp;&nbsp;房源信息</h5>
                    <hr>
                    <div class="col-xs-6"><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>楼栋</label>
                                <div class="col-xs-9">
                                    <select id="buildingname" name="buildingname" onchange="getBuildingHouseList()"
                                            type="text" class="form-control">
                                        <option value="">请选择楼栋</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>房源</label>
                                <div class="col-xs-9">
                                    <select id="housename" name="housename" type="text" class="form-control">
                                        <option value="">--</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div><!--end 换列-->
                </div><!--end row-->
            </div><!--end body-->
        </div>
        <!--------------------------房源 面板 end------------------------------------>

        <!-------------------------- 业主租客 面板  start--------------------------------->
        <div class="panel panel-primary">
            <div class="panel-body">
                <div class="row">
                    <h5>&nbsp;&nbsp;业主/租客信息</h5>
                    <hr>
                    <div class="col-xs-6"><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>业主/租客</label>
                                <div class="col-xs-9">
                                    <select id="conpanyname" name="conpanyname" class="form-control">
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>签订人</label>
                                <div class="col-xs-9">
                                    <input id="signer" name="signer" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>发票购方名称</label>
                                <div class="col-xs-9">
                                    <input id="billname" name="billname" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>联系方式</label>
                                <div class="col-xs-9">
                                    <input id="contracttel" name="contracttel" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>纳税人编号</label>
                                <div class="col-xs-9">
                                    <input id="billcompanyno" name="billcompanyno" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                    </div><!--end 换列-->
                </div><!--end row-->
            </div><!--end body-->
        </div>
        <!--------------------------业主租客 面板 end------------------------------------>

        <!-------------------------- 押金 面板  start--------------------------------->
        <div class="panel panel-primary">
            <div class="panel-body">
                <div class="row">
                    <h5>&nbsp;&nbsp;押金信息</h5>
                    <hr>
                    <div class="col-xs-6"><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"><font color="red">*</font> 押金金额(元)</label>
                                <div class="col-xs-9">
                                    <input id="yajin" name="yajin" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <!--如果输入元素是奇数个元素，在n=size/2?int时输出2列格式；如果元素是奇数个，需要在n=size/2?int+1时输出2列格式；需要换列，每行最多显示2列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>提前退租退还押金退占比（%）</label>
                                <div class="col-xs-9">
                                    <input id="yajinscale" name="yajinscale" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                    </div><!--end 换列-->

                </div><!--end row-->
            </div><!--end body-->
        </div>
        <!--------------------------押金 面板 end------------------------------------>

        <!-------------------------- 物业费 面板  start--------------------------------->
        <div class="panel panel-primary">
            <div class="panel-body">
                <div class="row">
                    <h5>&nbsp;&nbsp;租赁条款</h5>
                    <hr>
                    <div class="col-xs-6"><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font
                                        color="red">*</font>每月租金单价(元/平方米)</label>
                                <div class="col-xs-9">
                                    <input id="propertyprice" name="propertyprice" onchange="countPrice()" type="text" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <!--
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>计费类型</label>
                                <div class="col-xs-9">
                                    <select id="propertycounttype" name="propertycounttype" class="form-control">
                                        <option value="按月">按月</option>
                                        <option value="按天数">按天数</option>
                                    </select>
                                </div>
                            </div>
                        </div>-->
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>付费周期（月）</label>
                                <div class="col-xs-9">
                                    <select id="propertypaytype" name="propertypaytype" class="form-control">
                                        <option value="按月">按月</option>
                                        <option value="按季度">按季度</option>
                                        <option value="按半年">按半年</option>
                                        <option value="按年">按年</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"><font color="red">*</font>每月租金金额(元)</label>
                                <div class="col-xs-9">
                                    <input id="price" name="price" type="text"
                                           class="form-control"
                                           placeholder="" readonly="true" />(面积 * 租金单价(元/平方米*月))
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red"></font>租金递增开始时间</label>
                                <div class="col-xs-9">
                                    <input id="feiyongname" name="feiyongname" type="text" class="form-control"
                                           onclick='SelectDate(this)' readonly='true' placeholder=""/>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="col-xs-6">
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>面积(平方米)</label>
                                <div class="col-xs-9">
                                    <input id="area" name="area" type="text" onchange="countPrice()" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"><font color="red">*</font> 提前付款天数</label>
                                <div class="col-xs-9">
                                    <input id="propertyprepaydays" name="propertyprepaydays" type="text"
                                           class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>计费周期（月）</label>
                                <div class="col-xs-9">
                                    <select id="propertycounttype" name="propertycounttype" class="form-control">
                                        <option value="1">1</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-xs-3"> <font color="red">*</font>租金递增系数</label>
                                <div class="col-xs-9">
                                    <input id="rate" name="rate" type="text" value="1.0" class="form-control"
                                           placeholder=""/>
                                </div>
                            </div>
                        </div>
                    </div><!--end 换列-->
                </div><!--end row-->
            </div><!--end body-->
        </div>
        <!--------------------------物业费 面板 end------------------------------------>

        <div class="modal-footer bg-info " id='buttonDiv'>
        </div>
    </div>
    <!--------------------------费用信息 面板 end------------------------------------>

    <!-- 模态框（Modal）start -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="myModalMessDiv"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!-- 模态框（Modal）end -->
    </div>
</form>
</body>
</html>

<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!--<script src="<%=basePath%>js/jquery-1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrapValidator.js"></script>-->
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
<!-- <script src="<%=basePath%>js/additional-methods.min.js"></script> -->
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%= basePath %>js/tableSortTool.js"></script>
<script src="<%= basePath %>js/calendar.js"></script>
<script type="text/javascript">

    function compareDate() {
        var contractstartdate = $("#contractstartdate").val();
        var contractenddate = $("#contractenddate").val();
        if(contractenddate > contractstartdate ){
            return true;
        }else{
            return false;
        }
    }

    function countPrice(){
        var area = $("#area").val();
        var propertyprice = $("#propertyprice").val();
        //alert(area +":"+propertyprice);
        var price =  area*propertyprice;
        if(price!=null&&price!=""){
            $("#price").val(price.toFixed(2) );
        }
    }

    //新增保存数据
    function add() {
        if(compareDate()){
            $("#addSaveButton").attr("disabled", true);
            var url = "<%=basePath%>t_contract/saveT_contract?time=" + Math.random();
            var postData = $("#ffAdd").serializeArray();
            //alert(postData);
            $.post(url, postData, function (data) {
                //var data = $.parseJSON(data);
                if (data.result == "success") {
                    //保存成功  1.关闭弹出层，
                    showSuccessTips("恭喜保存成功!", "提示");
                    //history.goBack();
                } else {
                    $("#addSaveButton").removeAttr("disabled");
                    //showErrorTips("保存数据失败!", "错误信息：");
                    $("#myModal").modal('show'); //hide;
                    $("#myModalMessDiv").html("<font color='red'>对不起,保存数据失败，失败原因：" + data.info + "</font>");
                    return false;
                }
            }).error(function () {
                $("#addSaveButton").removeAttr("disabled");
                //showErrorTips("保存数据失败!", "错误信息：");
                $("#myModal").modal('show'); //hide;
                $("#myModalMessDiv").html("<font color='red'>对不起,保存数据失败，失败原因：" + data.info + "</font>");
            });
        }else{
            alert("合同结束时间 必须大于合同开始时间，请重新选择合同开始结束时间！");
        }
    }

    //更新修改数据到后台
    function edit() {
        if(compareDate()){
            $("#editSaveButton").attr("disabled", true);
            var url = "<%=basePath%>t_contract/updateT_contract?time=" + Math.random();
            myEdit2(url);
        }else{
            alert("合同结束时间 必须大于合同开始时间，请重新选择合同开始结束时间！");
        }
    }

    //更新修改数据到后台
    function creatBill() {
        insertrowsnum = insertrowsnum + 1; //全局变量加1；
        $("#billrowsnum").val(insertrowsnum);
        //alert("billrowsnum=" + $("#billrowsnum").val());
        var billstartdate = "billstartdate" + insertrowsnum;
        var billenddate = "billenddate" + insertrowsnum;
        var billarea = "billarea" + insertrowsnum;
        var billpaydate = "billpaydate" + insertrowsnum;
        var billfinalmone = "billfinalmone" + insertrowsnum;

        var str = "<tr>";
        str += "<td><input id='" + billstartdate + "' name='" + billstartdate + "' type='text' class='form-control' /></td>";
        str += "<td><input id='" + billenddate + "' name='" + billenddate + "' type='text' class='form-control' /></td>";
        str += "<td><input id='" + billarea + "' name='" + billarea + "' type='text' class='form-control' /></td>";
        str += "<td><input id='" + billpaydate + "' name='" + billpaydate + "' type='text' class='form-control' /></td>";
        str += "<td><input id='" + billfinalmone + "' name='" + billfinalmone + "' type='text' class='form-control' /></td>";
        str += "</tr>";
        $("#grid_body").append(str);
    }

    //更新修改数据到后台并且启动工作流
    function tjsh() {
        $("#editSaveButton").attr("disabled", true);
        $("#tjshSaveButton").attr("disabled", true);
        var url = "<%=basePath%>t_contract/tjshT_contract?time=" + Math.random();
        myCurdTjsh(url);
    }

    //获取楼栋房源列表信息
    function getBuildingHouseList() {
        $("select[name='housename']")[0].options.length = 0; //清空上一次初始化的值；
        var buildingname = $("select[name='buildingname']").val();
        //alert("buildingname="+buildingname);
        var url = "<%=basePath%>t_building_house/getAllT_building_house?buildingtype=1&buildingname=" + buildingname + "&startIndex=0&pageSize=10000&time=" + Math.random();
        //$.ajaxSettings.async = false;    //在执行之前加(同步执行)
        $.getJSON(url, function (data) {
            var str = "";
            $.each(data.items, function (i, item) {
                str += "<option value='" + item.housename + "'>" + item.housename + "</option>";
            });//end each data;
            $("#housename").append(str);
            //alert("str="+str);
        });//end getJSON;
    }

    //获取楼栋列表信息
    function getBuildingList() {
        var url = "<%=basePath%>t_building/getAllT_building?buildingtype=1&startIndex=0&pageSize=10000&time=" + Math.random();
        $.ajaxSettings.async = false;    //在执行之前加(同步执行)
        $.getJSON(url, function (data) {
            var str = "";
            $.each(data.items, function (i, item) {
                str += "<option value='" + item.name + "'>" + item.name + "</option>";
            });//end each data;
            $("#buildingname").append(str);
            //alert("str="+str);
        });//end getJSON;
    }

    //获取楼栋列表信息
    function getCompanyList() {
        var url = "<%=basePath%>t_company/getAllT_company?startIndex=0&pageSize=10000&time=" + Math.random();
        //$.ajaxSettings.async = false;    //在执行之前加(同步执行)
        $.getJSON(url, function (data) {
            var str = "";
            $.each(data.items, function (i, item) {
                str += "<option value='" + item.company_name + "'>" + item.company_name + "</option>";
            });//end each data;
            $("#conpanyname").append(str);
            //alert("str="+str);
        });//end getJSON;
    }

    //初始化页面及校验
    $().ready(function () {
        $.ajaxSettings.async = false; //作用域为{}内；
        getCompanyList();
        getBuildingList();

        //1、初始化数据显示
        var name = "租赁合同";
        var optype = '<%=request.getParameter("oplx")%>';
        var id = '<%=request.getParameter("id")%>';
        //alert("optype="+optype+";id="+id);
        if (optype == 'add') {
            $("#ffAdd")[0].reset();/*重置表单*/
            var basePath = "<i class='icon-plus'></i>&nbsp;";
            setHeader2("新增" + name, basePath);//设置addHeaderDiv标题文字及按钮
            setButtonDivAdd2();//设置adddiv的 操作按钮
        } else if (optype == 'edit') {
            var basePath = "<i class='icon-pencil'></i>&nbsp;";
            setHeader2("修改" + name, basePath);//设置addHeaderDiv标题文字及按钮
            setButtonDivEdit2();//设置adddiv的 操作按钮
            //setButtonDivEdit4();//设置adddiv的 操作按钮

            var url = "<%=basePath%>t_contract/getT_contract?id=" + id + "&time=" + Math.random();
            $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
                setValue(data);
                //alert(data.housename);
                $("#housename").append("<option value='" + data.housename + "' selected>" + data.housename + "</option>");
                //设置数字格式化值；
                number_formatInit('totalprice','totalpriceString')
                //alert($("#effect_date").val()+""+jsonDateFormat($("#effect_date").val()));
                //$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
            });
        } else if (optype == 'view') {
            var basePath = "<i class='icon-eye-open'></i>&nbsp;";//设置addHeaderDiv标题文字及按钮
            setHeader2("查看" + name, basePath);
            setButtonDivView2();//设置adddiv的 操作按钮

            var url = "<%=basePath%>t_contract/getT_contract?id=" + id + "&time=" + Math.random();
            $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
                setValue(data);
                $("#housename").append("<option value='" + data.housename + "' selected>" + data.housename + "</option>");
                //设置数字格式化值；
                number_formatInit('totalprice','totalpriceString')
                //alert($("#effect_date").val()+""+jsonDateFormat($("#effect_date").val()));
                //$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
            });
            formReadOnly('ffAdd');//设置表单不可修改
        }

        //2、校验脚本初始化，start check
        $("#ffAdd").validate({
            submitHandler: function (form) {
                //alert($("#opType").val());
                if ($("#opType").val() == "add") {
                    add();
                } else if ($("#opType").val() == "edit") {
                    edit();
                }
            },
            rules: {
                contractid: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                contractno: {
                    required: true,
                    maxlength: 256
                },
                conpanyid: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                conpanyname: {
                    required: true,
                    maxlength: 45
                },
                buildingno: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                buildingname: {
                    required: true,
                    maxlength: 45
                },
                houseid: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                housename: {
                    required: true,
                    maxlength: 1024
                },
                area: {
                    required: true,
                    number: true,
                    maxlength: 45
                },
                price: {
                    //required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 22
                },
                buildingtype: {
                    //required: true,
                    maxlength: 45
                },
                biztype: {
                    //required: true,
                    maxlength: 45
                },
                checkstatu: {
                    //required: true,
                    maxlength: 45
                },
                status: {
                    //required: true,
                    maxlength: 45
                },
                contracttype: {
                    //required: true,
                    maxlength: 45
                },
                linkman: {
                    required: true,
                    maxlength: 45
                },
                info: {
                    //required: true,
                    maxlength: 45
                },
                companytel: {
                    //required: true,
                    maxlength: 45
                },
                signer: {
                    required: true,
                    maxlength: 45
                },
                businesstype: {
                    //required: true,
                    maxlength: 45
                },
                attachpath: {
                    //required: true,
                    maxlength: 1024
                },
                totalprice: {
                    required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 14
                },
                totalpriceString: {
                    required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 14
                },
                signtime: {
                    required: true,
                    maxlength: 45
                },
                paytype: {
                    //required: true,
                    maxlength: 45
                },
                payday: {
                    //required: true,
                    maxlength: 45
                },
                creater: {
                    //required: true,
                    maxlength: 45
                },
                creattime: {
                    //required: true,
                    maxlength: 45
                },
                updater: {
                    //required: true,
                    maxlength: 45
                },
                updatetime: {
                    //required: true,
                    maxlength: 45
                },
                ext1: {
                    //required: true,
                    maxlength: 45
                },
                ext2: {
                    //required: true,
                    maxlength: 45
                },
                ext3: {
                    //required: true,
                    maxlength: 45
                },
                ext4: {
                    //required: true,
                    maxlength: 45
                },
                ext5: {
                    //required: true,
                    maxlength: 45
                },
                ext6: {
                    //required: true,
                    maxlength: 45
                },
                ext7: {
                    //required: true,
                    maxlength: 45
                },
                ext8: {
                    //required: true,
                    maxlength: 45
                },
                ext9: {
                    //required: true,
                    maxlength: 45
                },
                ext10: {
                    //required: true,
                    maxlength: 45
                },
                ext11: {
                    //required: true,
                    maxlength: 45
                },
                ext12: {
                    //required: true,
                    maxlength: 45
                },
                billname: {
                    required: true,
                    maxlength: 256
                },
                billcompanyno: {
                    required: true,
                    maxlength: 256
                },
                yajin: {
                    required: true,
                    number: true,
                    maxlength: 14
                },
                yajinscale: {
                    required: true,
                    number: true,
                    maxlength: 3
                },
                contracttel: {
                    required: true,
                    maxlength: 45
                },
                contractstartdate: {
                    required: true,
                    maxlength: 45
                },
                contractenddate: {
                    required: true,
                    maxlength: 45
                },
                htyajinunit: {
                    //required: true,
                    maxlength: 45
                },
                wuyedays: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                feiyongname: {
                    //required: true,
                    maxlength: 256
                },
                rate: {
                    //required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 22
                },
                huowumingcheng: {
                    //required: true,
                    maxlength: 512
                },
                youhuizhengce: {
                    //required: true,
                    maxlength: 512
                },
                youhuizhengcename: {
                    //required: true,
                    maxlength: 45
                },
                contractfeeunit: {
                    //required: true,
                    maxlength: 45
                },
                contractnumunit: {
                    //required: true,
                    maxlength: 45
                },
                contractprice: {
                    required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 22
                },
                contractcounttype: {
                    required: true,
                    maxlength: 45
                },
                contractpaytype: {
                    required: true,
                    maxlength: 45
                },
                contractprepaydays: {
                    required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                contractyeardays: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                contractdatetype: {
                    //required: true,
                    maxlength: 45
                },
                energyfeeunit: {
                    //required: true,
                    maxlength: 45
                },
                energytnumunit: {
                    //required: true,
                    maxlength: 45
                },
                energytprice: {
                    required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 22
                },
                energycounttype: {
                    required: true,
                    maxlength: 45
                },
                energypaytype: {
                    required: true,
                    maxlength: 45
                },
                energyprepaydays: {
                    required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                energyyeardays: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                energytdatetype: {
                    //required: true,
                    maxlength: 45
                },
                propertyfeeunit: {
                    //required: true,
                    maxlength: 45
                },
                propertynumunit: {
                    //required: true,
                    maxlength: 45
                },
                propertyprice: {
                    required: true,
                    number: true,
                    //minlength: 1,
                    maxlength: 14
                },
                propertycounttype: {
                    required: true,
                    maxlength: 45
                },
                propertypaytype: {
                    required: true,
                    maxlength: 45
                },
                propertyprepaydays: {
                    required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                propertyyeardays: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                propertydatetype: {
                    //required: true,
                    maxlength: 45
                }
            }, //end rules;
            messages: {
                contractid: {
                    //required: " contractid不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> contractid最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                contractno: {
                    required: " <font color='red'> 不能为空！</font>！",
                    maxlength: "<font color='red'> 最大支持128位,输入的数据已经超过最大长度！</font>"
                },
                conpanyid: {
                    //required: " conpanyid不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> conpanyid最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                conpanyname: {
                    required: " <font color='red'> 不能为空！</font>！",
                    maxlength: "<font color='red'> 最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                buildingno: {
                    //required: " buildingno不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> buildingno最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                buildingname: {
                    required: " 不能为空！",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                houseid: {
                    //required: " houseid不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> houseid最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                housename: {
                    required: " <font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'> housename最大支持1,024位,输入的数据已经超过最大长度！</font>"
                },
                area: {
                    required: " <font color='red'>不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                price: {
                    //required: true,
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>单价最大支持22位,输入的数据已经超过最大长度！</font>"
                },
                buildingtype: {
                    maxlength: "<font color='red'> buildingtype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                biztype: {
                    maxlength: "<font color='red'> biztype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                checkstatu: {
                    maxlength: "<font color='red'> checkstatu最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                status: {
                    maxlength: "<font color='red'> status最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                contracttype: {
                    maxlength: "<font color='red'> contracttype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                linkman: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                info: {
                    maxlength: "<font color='red'> info最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                companytel: {
                    maxlength: "<font color='red'> companytel最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                signer: {
                    required: "<font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'>签订人最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                businesstype: {
                    maxlength: "<font color='red'>行业最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                attachpath: {
                    maxlength: "<font color='red'> attachpath最大支持1,024位,输入的数据已经超过最大长度！</font>"
                },
                totalprice: {
                    required: "<font color='red'>不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>总价最大支持14位,输入的数据已经超过最大长度！</font>"
                },
                totalpriceString: {
                    required: "<font color='red'>不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>总价最大支持14位,输入的数据已经超过最大长度！</font>"
                },
                signtime: {
                    required: "<font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                paytype: {
                    maxlength: "<font color='red'> paytype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                payday: {
                    maxlength: "<font color='red'>付款时间最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                creater: {
                    maxlength: "<font color='red'> creater最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                creattime: {
                    maxlength: "<font color='red'> creattime最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                updater: {
                    maxlength: "<font color='red'> updater最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                updatetime: {
                    maxlength: "<font color='red'> updatetime最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext1: {
                    maxlength: "<font color='red'> ext1最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext2: {
                    maxlength: "<font color='red'> ext2最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext3: {
                    maxlength: "<font color='red'> ext3最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext4: {
                    maxlength: "<font color='red'> ext4最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext5: {
                    maxlength: "<font color='red'> ext5最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext6: {
                    maxlength: "<font color='red'> ext6最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext7: {
                    maxlength: "<font color='red'> ext7最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext8: {
                    maxlength: "<font color='red'> ext8最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext9: {
                    maxlength: "<font color='red'> ext9最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext10: {
                    maxlength: "<font color='red'> ext10最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext11: {
                    maxlength: "<font color='red'> ext11最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                ext12: {
                    maxlength: "<font color='red'> ext12最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                billname: {
                    required: "<font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'> billname最大支持256位,输入的数据已经超过最大长度！</font>"
                },
                billcompanyno: {
                    required: "<font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持128位,输入的数据已经超过最大长度！</font>"
                },
                yajin: {
                    required: "<font color='red'>不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    maxlength: "<font color='red'>押金金额最大支持14位,输入的数据已经超过最大长度！</font>"
                },
                yajinscale: {
                    required: "<font color='red'>不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    maxlength: "<font color='red'> 最大支持3位,输入的数据已经超过最大长度！</font>"
                },
                contracttel: {
                    required: " <font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                contractstartdate: {
                    required: " <font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                contractenddate: {
                    required: " <font color='red'>不能为空！</font>",
                    maxlength: "<font color='red'>最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                htyajinunit: {
                    maxlength: "<font color='red'> htyajinunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                wuyedays: {
                    //required: " wuyedays不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> wuyedays最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                feiyongname: {
                    maxlength: "<font color='red'>费用名称最大支持256位,输入的数据已经超过最大长度！</font>"
                },
                rate: {
                    //required: true,
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>税率最大支持22位,输入的数据已经超过最大长度！</font>"
                },
                huowumingcheng: {
                    maxlength: "<font color='red'>货物名称最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                youhuizhengce: {
                    maxlength: "<font color='red'> youhuizhengce最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                youhuizhengcename: {
                    maxlength: "<font color='red'> youhuizhengcename最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                contractfeeunit: {
                    maxlength: "<font color='red'> contractfeeunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                contractnumunit: {
                    maxlength: "<font color='red'> contractnumunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                contractprice: {
                    required: "<font color='red'> 不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>  最大支持22位,输入的数据已经超过最大长度！</font>"
                },
                contractcounttype: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'>  最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                contractpaytype: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'>  最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                contractprepaydays: {
                    required: "<font color='red'> 不能为空！</font>",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> 最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                contractyeardays: {
                    //required: " contractyeardays不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> contractyeardays最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                contractdatetype: {
                    maxlength: "<font color='red'> contractdatetype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                energyfeeunit: {
                    maxlength: "<font color='red'> energyfeeunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                energytnumunit: {
                    maxlength: "<font color='red'> energytnumunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                energytprice: {
                    required: "<font color='red'> 不能为空！</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>  最大支持14位,输入的数据已经超过最大长度！</font>"
                },
                energycounttype: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                energypaytype: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'> energypaytype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                energyprepaydays: {
                    required: "<font color='red'>不能为空！</font>",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> 最大支持3位，输入的数据已经超过最大长度！</font>"
                },
                energyyeardays: {
                    //required: " energyyeardays不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> energyyeardays最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                energytdatetype: {
                    maxlength: "<font color='red'> energytdatetype最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                propertyfeeunit: {
                    maxlength: "<font color='red'> propertyfeeunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                propertynumunit: {
                    maxlength: "<font color='red'> propertynumunit最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                propertyprice: {
                    required: "<font color='red'> 不能为空</font>",
                    number: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> 最大支持14位,输入的数据已经超过最大长度！</font>"
                },
                propertycounttype: {
                    required: "<font color='red'> 不能为空</font>",
                    maxlength: "<font color='red'> 最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                propertypaytype: {
                    required: "<font color='red'> 不能为空</font>",
                    maxlength: "<font color='red'> 最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                propertyprepaydays: {
                    required: " <font color='red'>不能为空！</font>！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>  最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                propertyyeardays: {
                    //required: " propertyyeardays不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'> propertyyeardays最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                propertydatetype: {
                    maxlength: "<font color='red'> propertydatetype最大支持45位,输入的数据已经超过最大长度！</font>"
                }
            } //end message;
        }); //end validate;
    }) //end funciton read;
</script>

